<?php

namespace app\api\controller\v1;

use think\Request;
use app\api\controller\Home;
use app\common\model\ArticleModel;

class Article extends Home {
    public function index(Request $request){
        $cid = $request->param('cid');
        $cate = new ArticleModel();
        if(isset($cid)){
            $list = $cate->where('cid',$cid)->paginate();
        }else{
            $list = $cate->paginate();
        }
//        $domain = $request->domain();
//        foreach($list as $v){
//            $v['img'] = $domain.$v['img'];
//        }
        return json(['code'=>1,'msg'=>'ok','data'=>$list]);
    }
    
    public function read(Request $request) {
        $id = $request->param('id');
        $article = new ArticleModel();
        $info = $article->find($id);
        return json(['code'=>1,'msg'=>'ok','data'=>$info]);
    }
}

?>